package com.zmm.zebulon.starter.api.log.core.service;

import cn.hutool.core.bean.BeanUtil;
import com.zmm.zebulon.module.infra.api.api.ApiAccessLogApi;
import com.zmm.zebulon.module.infra.api.api.dto.ApiAccessLogCreateReqDTO;
import com.zmm.zebulon.starter.api.log.core.domain.ApiAccessLog;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Async;

/**
 * description: API 访问日志 Framework Service 实现类<br>
 * 基于 {@link ApiAccessLogApi} 服务，记录访问日志
 *
 * @author zebulon
 * package com.zmm.zebulon.starter.web.api.log.core.service
 * name: ApiAccessLogFrameworkServiceImpl
 * date 2024/1/12 22:46
 */
@RequiredArgsConstructor
public class ApiAccessLogFrameworkServiceImpl implements ApiAccessLogFrameworkService {

    private final ApiAccessLogApi apiAccessLogApi;

    @Override
    @Async
    public void createApiAccessLog(ApiAccessLog apiAccessLog) {
        ApiAccessLogCreateReqDTO reqDTO = BeanUtil.copyProperties(apiAccessLog, ApiAccessLogCreateReqDTO.class);
        apiAccessLogApi.createApiAccessLog(reqDTO);
    }

}
